package com.wangcanxuan.www.controller.Impl;

import com.wangcanxuan.www.controller.TaskController;
import com.wangcanxuan.www.entity.dto.ResultInfo;
import com.wangcanxuan.www.entity.po.Task;
import com.wangcanxuan.www.entity.po.User;
import com.wangcanxuan.www.proxy.ServiceProxy;
import com.wangcanxuan.www.service.Impl.TaskServiceImpl;
import com.wangcanxuan.www.service.TaskService;

import java.util.List;

/**
 * 任务Controller层实现类
 *
 * @author HHLJ
 * @date 2022/04/07
 */
public class TaskControllerImpl implements TaskController {
    private final TaskService taskService = ServiceProxy.getProxyInstance(TaskServiceImpl.class);

    @Override
    public ResultInfo<List<Task>> selectTaskList(String tribeId, int pageCount) {
        return taskService.selectTaskList(tribeId, pageCount);
    }


    @Override
    public ResultInfo<String> publishTask(String taskName, String taskContent, int level, User user) {
        ResultInfo<String> resultInfo = taskService.publishTask(taskName, taskContent, level, user);
        if (resultInfo.isSuccess()) {
            resultInfo.setMessage("任务发布成功！");
        }
        return resultInfo;
    }

    @Override
    public ResultInfo<String> shelvesTask(String chooseTaskName, String tribeId) {

        ResultInfo<String> resultInfo = taskService.shelvesTask(chooseTaskName, tribeId);
        if (resultInfo.isSuccess()) {
            resultInfo.setMessage("下架任务成功！");
        }
        return resultInfo;
    }

    @Override
    public ResultInfo<List<Task>> selectTaskListByUser(User user) {
        return taskService.selectTaskListByUser(user);
    }

    @Override
    public ResultInfo<String> acceptTask(User user, String chooseTaskName) {
        ResultInfo<String> resultInfo =taskService.acceptTask(user, chooseTaskName);
        if (resultInfo.isSuccess()) {
            resultInfo.setMessage("接受任务成功！");
        }
        return resultInfo;
    }
}
